﻿package app.view.components.sections 
{
	import app.interfaces.ISection;
	import app.model.vo.SectionVO;
	import gs.TweenLite;
	import org.casalib.display.CasaSprite;
	
	/**
	 * Базовый класс для всех секций ( и возможно попаов)
	 * @author firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class Section extends CasaSprite implements ISection
	{
		// идентификатор
		public var id:String;
		// данные
		protected var _data:Object;
		protected var _datapopup:Object;
		// параметры
		protected var _params:Object;
		// настройки скрытия/показа
		private var _openDuration:Number = 0.4;
		private var _closeDuration:Number = 0.4;
		
		public function Section() 
		{
			super();
			init();
		};
		
		protected function init():void 
		{
			////trace('[D:] блаааааааааааааааааа');
			alpha = 0;
		};
		
		public function open(immediate:Boolean = false):void 
		{
			if ( immediate ) 
			{
				alpha = 1;
				mouseChildren = mouseEnabled = true;
				return;
			};
			TweenLite.to ( this, _openDuration, { alpha : 1 } );
		}
		
		public function close(immediate:Boolean = false):void 
		{
			if ( immediate ) 
			{
				alpha = 0;
				mouseChildren = mouseEnabled = false;
				return;
			};
			TweenLite.to ( this, _closeDuration, { alpha : 0 } );
		};
		
		override public function destroy():void 
		{
			mouseChildren = mouseEnabled = false;
			TweenLite.to ( this, _closeDuration, { alpha : 0, onComplete: onDestroy } );			
		};
		
		public function onDestroy():void
		{
			super.destroy();
		}
		
		public function get data():Object { return _data; };
		
		public function set data(value:Object):void 
		{
			//SectionVO
			_data = value;
		};
		
		public function get params():Object { return _params; };
		
		public function set params(value:Object):void 
		{
			_params = value;
		};
		
		public function get datapopup():Object { return _datapopup; }
		
		public function set datapopup(value:Object):void 
		{
			_datapopup = value;
		}
	};
};